// Kony

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "NiagaraSystem.h"
#include "NiagaraComponent.h"
#include "TargetLockComponent.generated.h"

//目标锁定状态广播
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTargetLockChanged, AActor*, TargetActor, bool, bIsLocked);

/**
 * 目标锁定组件
 */
UCLASS()
class GASC_HUANLING_API UTargetLockComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	UTargetLockComponent();

	//显示目标指示器
	UFUNCTION(BlueprintCallable, Category = "TargetLock")
	void ShowTargetIndicator();
	
	//隐藏目标指示器
	UFUNCTION(BlueprintCallable, Category = "TargetLock")
	void HideTargetIndicator();

	//目标锁定状态广播
	UPROPERTY(BlueprintAssignable, Category = "TargetLock")
	FOnTargetLockChanged OnTargetLockChanged;

protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	//目标锁定特效系统
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "TargetLock")
	UNiagaraSystem* TargetLockEffect;

	//特效相对位置偏移
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TargetLock")
	FVector EffectOffset = FVector(0.0f, 0.0f, -90.0f);

private:
	//当前是否被锁定
	bool bIsTargetLocked = false;

	//特效组件实例
	UPROPERTY()
	UNiagaraComponent* EffectComponent;

	//角色死亡回调
	UFUNCTION()
	void OnOwnerDeath(AActor* DeadActor);
};